package com.dkd.common.utils.uuid;

public class UUIDUtils {

    //字符集
    private static final char[] chars = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();

    public static String getUUID(){
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        StringBuilder shortBuilder = new StringBuilder();
        //把UUID字符串分为8组进行处理
        for (int i = 0; i < 8; i++) {
            String str = uuid.substring(i * 4, i * 4 + 4);
            //将当前的4个字符转换成16进制整数
            int x = Integer.parseInt(str, 16);
            //使用该整数对预定义的字符集取模
            shortBuilder.append(chars[x%0x3E]);
        }
        return shortBuilder.toString();
    }

}
